#!/usr/bin/make -f
# -*- makefile -*-
# debian/rules for yaal project package that uses debhelper.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export PREFIX=/usr
export SYSCONFDIR=/etc
export LOCALSTATEDIR=/var
unexport SHAREDSTATEDIR

ifneq ($(PACKAGE_VERSION),)
override_dh_gencontrol=override_dh_gencontrol
endif

.PHONY: \
	override_dh_auto_build \
	override_dh_auto_clean \
	override_dh_auto_configure \
	override_dh_auto_install \
	override_dh_autoreconf \
	override_dh_dwz \
	$(override_dh_gencontrol) \
	override_dh_shlibdeps \
	override_dh_strip

dropprivs: ./_aux/dropprivs.c
	$(CC) $(<) -o $(@)

override_dh_auto_clean: dropprivs
	umask 0077 && ./dropprivs dh_auto_clean && /bin/rm -fr ./dropprivs ./debian/tmp

override_dh_auto_build: dropprivs
	umask 0077 && ./dropprivs env -u CXXFLAGS -u CFLAGS -u CPPFLAGS -u LDFLAGS dh_auto_build -Sautoconf -- CONFIGURE="--enable-auto-sanity" debug release doc

override_dh_auto_test: dropprivs
	umask 0077 && ./dropprivs dh_auto_test -- test

override_dh_auto_install: dropprivs
	umask 0077 && ./dropprivs dh_auto_install -Sautoconf -- install-debug install-release

ifneq ($(PACKAGE_VERSION),)
override_dh_gencontrol:
	dh_gencontrol -- -v$(PACKAGE_VERSION)
endif

override_dh_shlibdeps:
	dh_shlibdeps -Xyaal_sqlite3_driver -Xyaal_postgresql_driver -Xyaal_mysql_driver -Xyaal_firebird_driver -Xyaal_oracle_driver

override_dh_dwz:
	dh_dwz --no-dwz-multifile

%: dropprivs
	./dropprivs dh $(@)

